#pragma once
//#include "stdafx.h"
#include "mac.h"
#include "SpaceAgent.h"
namespace LPS
{
	using namespace org::spark::core;
	using namespace org::spark::data;
	using namespace org::spark::space;
	using namespace org::spark::math;

	void mac::_init()
	{
	}

	mac::mac()
	{
		InitializeInstanceFields();
		_init();
	}

	void mac::macFunction()
	{
		this->wiggle(1.0);
		this->sniff(LPSmodel::LPS, 0.0);
		if ((LPSmodel::LPS->getValue(this) > 0.01))
		{
			double macRecruit = 0;

			if ((LPSmodel::macActLPS > RandomHelper::random(1.0)))
			{
				this->activated = true;
			}
			macRecruit = (ceil(LPSmodel::LPS->getValue(this)) / LPSmodel::macProp);
			int _nn = static_cast<int>(macRecruit);
			mac **_objects;
			for (int _i = 0; _i < _nn; _i++)
			{	

				_objects[_i] = new mac();
			}
			if (_objects != 0)
			{
				for (int _i1 = 0; _i1 < sizeof(_objects) / sizeof(_objects[0]); _i1++)
				{
					mac *__agent3 = _objects[_i1];
					//__agent3->setColor((std::vector(204.0 / 255.0, 102.0 / 255.0, 0)));
					__agent3->jump(20.0);
					__agent3->jump(RandomHelper::random(50.0));
					__agent3->age = (RandomHelper::random(40.0) + LPSmodel::macAge);
					__agent3->activated = false;
				}
			}
		}
		if ((LPSmodel::pro->getValue(this) > 0.01))
		{
			if ((LPSmodel::macActPro > RandomHelper::random(1.0)))
			{
				this->activated = true;
			}
		}
		if ((LPSmodel::damage->getValue(this) > 0.01))
		{
			if ((LPSmodel::macActDam > RandomHelper::random(1.0)))
			{
				this->activated = true;
			}
		}
		if (this->activated)
		{
			am *_agent;
			_agent = new am();
			_agent->moveToSpace(this->getSpace(), this->getPosition());
			if (_agent != 0)
			{
				am *__agent3 = _agent;
				__agent3->age = (this->age + LPSmodel::macAge);
				//__agent3->setColor(SpaceAgent::CYAN);
			}
			this->die();
			return;
		}
		this->age -= 1.0;
		if ((this->age < 0.0))
		{
			this->die();
		}
	}

	void mac::InitializeInstanceFields()
	{
		activated = false;
	}
}
